#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.test import TestCase

# Create your tests here.

# 导入redis连接库
# from django_redis import get_redis_connection
#
# # 获取redis连接，这里的speaker指的是在settings.py里面配置的指定数据库
# redis_conn = get_redis_connection('speaker')
#
# # 存入一个有效期为300秒的数据，前面是key，后面是value
# redis_conn.setex('speaker_key', 300, 'speaker_value')
#
# # 存入一个普通的值
# redis_conn.set('speaker_key', 'speaker_value')
#
#
# # 也可以使用管道，优化减少redis连接次数
# pipeline = redis_conn.pipeline()
#
# # 塞入管道
# pipeline.setex('speaker_key', 300, 'speaker_value')
# pipeline.set('speaker_key', 'speaker_value')
#
# # 执行管道
# pipeline.execute()

# if __name__ == '__main__':
#     from celery_tasks.speaker_monitor.tasks import get_connect_speaker
#     get_connect_speaker.delay()
#     print('下面的内容')

# if __name__ == '__main__':
#     import win32com.client
#
#     ADB_LINUX = 0
#     ADB_PID_VID = 'VID_2207&PID_0006\\\\'
#     CH340_PID_VID = 'VID_1A86&PID_7523\\\\'
#     device_list = []
#     wmi = win32com.client.GetObject("winmgmts:")
#     for usb in wmi.InstancesOf("win32_usbcontrollerdevice"):
#         if ADB_PID_VID in usb.Dependent:
#             infos = {'device_type': ADB_LINUX, 'port': usb.Dependent.split(ADB_PID_VID)[1][:-1]}
#             device_list.append(infos)
#         if CH340_PID_VID in usb.Dependent:
#             infos = {'device_type': 'COM', 'port': usb.Dependent.split(CH340_PID_VID)[1][:-1]}
#             device_list.append(infos)
#     print(device_list)
#
# if __name__ == '__main__':
#     import redis
#     pool = redis.ConnectionPool(host='127.0.0.1', port=6379, password='123456', db="0")
#     con = redis.Redis(connection_pool=pool)
#     import random
#
#     # x = random.randint(1, 1000)
#
#     con.hset('speaker_02', 'sn', '999999999999999')
#     con.hset('speaker_02', 'rom_verison', '1.6.99')
#     con.hset('speaker_02', 'detail', '串口设备')
#     keys = con.keys()
#     for i in keys:
#         print(i.decode())
